/**
 * @filename SessionInViewInterceptor.java
 */
package com.liupf.interceptor;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpSession;

import com.jfinal.aop.Interceptor;
import com.jfinal.core.ActionInvocation;
import com.liupf.common.utils.TypeConstant;
import com.liupf.common.utils.TypeConstant.OrderStatusType;

/**
 * @description
 * @author shevliu
 * @email shevliu@gmail.com Jul 28, 2012 1:21:23 AM
 */
public class SessionInViewInterceptor implements Interceptor {
	public void intercept(ActionInvocation ai) {
		ai.invoke();
		HttpSession hs = ai.getController().getSession(false);
		if (hs != null) {
			Map session = new HashMap();
			ai.getController().setAttr("session", session);
			for (Enumeration<String> names = hs.getAttributeNames(); names
					.hasMoreElements();) {
				String name = names.nextElement();
				session.put(name, hs.getAttribute(name));
			}
			OrderStatusType[] orderStatusTypeArray = TypeConstant.OrderStatusType.values();
			session.put("orderStatusTypeArray",orderStatusTypeArray);
			
			/*Map<String,String> orderStatusMap = new HashMap<String, String>();
			orderStatusMap.put("0", "未接收");
			orderStatusMap.put("1", "待接收");
			orderStatusMap.put("2", "已到达");
			orderStatusMap.put("3", "开始代驾");
			orderStatusMap.put("4", "完成");
			orderStatusMap.put("6", "待分配");
			orderStatusMap.put("7", "临时订单");
			orderStatusMap.put("8", "未接取消待审核");
			orderStatusMap.put("9", "已接取消待审核");
			orderStatusMap.put("10", "未接订单取消已审核");
			orderStatusMap.put("11", "已接订单取消已审核");
			orderStatusMap.put("12", "撤销待审核");
			orderStatusMap.put("13", "撤销已审核");
			orderStatusMap.put("14", "临时订单审核");
			session.put("orderStatusMap",orderStatusMap);*/
			
			/*orderStatusMap.put("0", "未接收");
			orderStatusMap.put("1", "待接收");
			orderStatusMap.put("2", "已到达");
			orderStatusMap.put("3", "开始代驾");
			orderStatusMap.put("4", "完成");
			orderStatusMap.put("6", "待分配");
			orderStatusMap.put("7", "临时订单");
			orderStatusMap.put("8", "未接取消待审核");
			orderStatusMap.put("9", "已接取消待审核");
			orderStatusMap.put("10", "未接订单取消已审核");
			orderStatusMap.put("11", "已接订单取消已审核");
			orderStatusMap.put("12", "撤销待审核");
			orderStatusMap.put("13", "撤销已审核");
			orderStatusMap.put("14", "临时订单审核");*/
		}
	}
}
